package com.shujia.car.batch.jtqj

import java.io.InputStream
import scala.io.Source

object ZqzfKjUtil {

  /**
   * 获取指标统计口径
   *
   */
  def getKJ: Map[String, List[String]] = {
    val inputStream: InputStream = this
      .getClass // 获取类对象
      .getClassLoader // 获取类加载器
      .getResourceAsStream("zqzf_kj.txt") //从resources获取一个输入流

    val kjs: List[String] = Source.fromInputStream(inputStream).getLines().toList

    //解析数据转换成kv格式
    val kvList: List[(String, List[String])] = kjs.map(kv => {
      val split: Array[String] = kv.split("-")
      val index: String = split.head
      val kj: List[String] = split.last.split(",").toList
      (index, kj)
    })
    //转换成map集合返回
    kvList.toMap
  }

  def main(args: Array[String]): Unit = {
    val kjMap: Map[String, List[String]] = getKJ
    println(kjMap("yjjs"))
  }

}
